//
//  huaiheWebVC.m
//  huaihe
//
//  Created by 暗流澎涌 on 2024/3/9.
//

#import "huaiheWebVC.h"
#import <WebKit/WebKit.h>

#import <Masonry/Masonry.h>

@interface huaiheWebVC ()<WKNavigationDelegate, WKScriptMessageHandler>
@property (strong, nonatomic) WKWebView *huaihe_webView;
@property (weak, nonatomic) IBOutlet UIView *topview;

@property (weak, nonatomic) IBOutlet UIView *secView;
@property (weak, nonatomic) IBOutlet UILabel *hadTitle;

@end

@implementation huaiheWebVC
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setHidden: YES];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setHidden: NO];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.hadTitle.text  = self.huaihetitle;
    [self initUI];
}
- (IBAction)backTOhome:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initUI {
    self.topview.backgroundColor = [UIColor colorWithRed:221.0/255.0 green:43.0/255.0 blue:21.0/255.0 alpha:1];
    self.secView.backgroundColor = [UIColor colorWithRed:221.0/255.0 green:43.0/255.0 blue:21.0/255.0 alpha:1];
    
    WKWebViewConfiguration *huaihe_configuration = [[WKWebViewConfiguration alloc] init];
   
    self.huaihe_webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) configuration:huaihe_configuration];
    [self.view addSubview:self.huaihe_webView];
            [self.huaihe_webView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.right.bottom.equalTo(@0);
                make.top.equalTo(@84);
            }];
    self.huaihe_webView.navigationDelegate = self;
    self.huaihe_webView.backgroundColor = UIColor.whiteColor;
    self.huaihe_webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    [self.huaihe_webView setHidden:NO];
    if (self.Huaihe_url) {
        NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.Huaihe_url]];
        [self.huaihe_webView loadRequest:request];
    }
}
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
    NSLog(@"error = %@",error);
}


@end
